package com.probox.systemApi.factory;

import com.probox.systemApi.RemoteCustomerService;
import com.probox.systemApi.model.LoginUser;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 用户服务降级处理
 *
 * @author usoft
 */
@Component
public class RemoteCustomerFallbackFactory implements FallbackFactory<RemoteCustomerService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteCustomerFallbackFactory.class);

    @Override
    public RemoteCustomerService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteCustomerService()
        {
            @Override
            public boolean addCustomerToken(LoginUser loginUser) {
                return false;
            }
        };
    }
}
